package cn.iocoder.yudao.module.course.dal.mysql.courses;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.course.dal.dataobject.courses.CoursesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.course.controller.admin.courses.vo.*;

/**
 * 课程 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CoursesMapper extends BaseMapperX<CoursesDO> {

    default PageResult<CoursesDO> selectPage(CoursesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CoursesDO>()
                .eqIfPresent(CoursesDO::getTitle, reqVO.getTitle())
                .eqIfPresent(CoursesDO::getDescription, reqVO.getDescription())
                .eqIfPresent(CoursesDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(CoursesDO::getCoverImage, reqVO.getCoverImage())
                .eqIfPresent(CoursesDO::getVersion, reqVO.getVersion())
                .eqIfPresent(CoursesDO::getDeptId, reqVO.getDeptId())
                .betweenIfPresent(CoursesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CoursesDO::getId));
    }

}